<template>
  <div>
    <a-form-model
      ref="ruleForm"
      :model="form"
      :rules="rules"
      :label-col="labelCol"
      :wrapper-col="wrapperCol"
    >

      <a-form-model-item label="化解时限" required prop="defuseDate">
        <a-date-picker v-model="form.defuseDate" @change="onChange1" />
      </a-form-model-item>
      <a-form-model-item label="化解方式" prop="defuseMode">
        <a-select v-model="form.defuseMode" placeholder="请选择">
<!--          <a-select-option v-for="(item,index) of this.filterMultiDictText('defuse_mode','')" :value="item.value" :key="index">-->
<!--            {{item.text}}-->
<!--          </a-select-option>-->
          <a-select-opt-group label="调解">
            <a-select-option value="0101">
              {{ this.filterMultiDictText1('defuse_mode','0101') }}
            </a-select-option>
            <a-select-option value="0102">
              {{ this.filterMultiDictText1('defuse_mode','0102') }}
            </a-select-option>
            <a-select-option value="0103">
              {{ this.filterMultiDictText1('defuse_mode','0103') }}
            </a-select-option>
            <a-select-option value="0104">
              {{ this.filterMultiDictText1('defuse_mode','0104') }}
            </a-select-option>
            <a-select-option value="0105">
              {{ this.filterMultiDictText1('defuse_mode','0105') }}
            </a-select-option>
            <a-select-option value="0106">
              {{ this.filterMultiDictText1('defuse_mode','0106') }}
            </a-select-option>
            <a-select-option value="0107">
              {{ this.filterMultiDictText1('defuse_mode','0107') }}
            </a-select-option>
            <a-select-option value="0199">
              {{ this.filterMultiDictText1('defuse_mode','0199') }}
            </a-select-option>
          </a-select-opt-group>
          <a-select-opt-group label="仲裁">
            <a-select-option value="0201">
              {{ this.filterMultiDictText1('defuse_mode','0201') }}
            </a-select-option>
            <a-select-option value="0202">
              {{ this.filterMultiDictText1('defuse_mode','0202') }}
            </a-select-option>
            <a-select-option value="0203">
              {{ this.filterMultiDictText1('defuse_mode','0203') }}
            </a-select-option>
            <a-select-option value="0204">
              {{ this.filterMultiDictText1('defuse_mode','0204') }}
            </a-select-option>
          </a-select-opt-group>
          <a-select-option value="03">
            {{ this.filterMultiDictText1('defuse_mode','03') }}
          </a-select-option>
          <a-select-option value="04">
            {{ this.filterMultiDictText1('defuse_mode','04') }}
          </a-select-option>
          <a-select-option value="05">
            {{ this.filterMultiDictText1('defuse_mode','05') }}
          </a-select-option>
          <a-select-option value="06">
            {{ this.filterMultiDictText1('defuse_mode','06') }}
          </a-select-option>
        </a-select>
      </a-form-model-item>
      <a-form-model-item ref="name" label="化解组织" prop="defuseOrganization">
        <a-input v-model="form.defuseOrganization" placeholder="请输入"/>
      </a-form-model-item>
      <a-form-model-item ref="name" label="化解责任人姓名" prop="personLiable">
        <a-input v-model="form.personLiable" placeholder="请输入"/>
      </a-form-model-item>
      <a-form-model-item ref="name" label="化解责任人联系方式" prop="contactInformation">
        <a-input v-model="form.contactInformation" placeholder="请输入"/>
      </a-form-model-item>
      <a-form-model-item ref="name" label="是否化解成功" prop="defuseSuccess">
        <a-switch default-checked v-model="form.defuseSuccess" @change="onChange5">
          <a-icon slot="checkedChildren" type="check" />
          <a-icon slot="unCheckedChildren" type="close" />
        </a-switch>
      </a-form-model-item>
      <a-form-model-item label="化解情况" prop="defuseSituation">
        <a-input v-model="form.defuseSituation" type="textarea" placeholder="请输入" />
      </a-form-model-item>
    </a-form-model>
  </div>
</template>

<script>
import { getDictItemsFromCache } from '@api/api'
import { updata } from '@api/xlgc/lawCase'
import Input from '@/views/xlgc/lawCase/LifeCase/detailed/ImportModal'
export default {
  name: 'basic',
  components:{Input},
  props:{
    basics:Number
  },
  data() {
    return {
      visible:false,
      fileList:[],
      labelCol: { span: 10 },
      wrapperCol: { span: 6 },
      other: '',
      form: {
        contactInformation: "",
        defuseDate: "",
        defuseMode: "",
        defuseOrganization: "",
        defuseSituation: "",
        defuseSuccess: 0,
        personLiable: "",
      },
      rules: {
        defuseDate: [{ required: true, message: '请选定化解时限', trigger: 'blur' }],
        personLiable: [{ required: true, message: '请输入化解责任人姓名', trigger: 'change' }],
        contactInformation: [
          { required: true, message: '请输入化解人联系方式', trigger: 'change' },
          // {pattern:/^(13[0-9]{9}$|14[0-9]{9}|15[0-9]{9}$|18[0-9]{9})$|(^(0\d{10})|^(0\d{2}-\d{8}))$/,message: '请输入正确的联系方式',}

        ],
        defuseSuccess: [{ required: false, message: '请选择', trigger: 'change' }],
        defuseMode: [{ required: true, message: '请选择', trigger: 'change' }],
        defuseOrganization: [{ required: true, message: '请输入化解组织', trigger: 'change' }],
        defuseSituation	: [
          { required: true, message: '事件概述', trigger: 'blur' },
          { min: 5, message: '请输入至少五个字符', trigger: 'blur' }
        ],
      },
      dateFormat: 'YYYY-MM-DD',
    };
  },
  methods: {
    setControl(obj){
      console.log(obj)
      // this.form = obj
      this.form.contactInformation = obj[0].contactInformation
      this.form.defuseDate = obj[0].defuseDate
      this.form.defuseMode = obj[0].defuseMode
      this.form.defuseOrganization = obj[0].defuseOrganization
      this.form.defuseSituation = obj[0].defuseSituation
      this.form.defuseSuccess = obj[0].defuseSuccess === '1'
      this.form.personLiable = obj[0].personLiable
      console.log(this.form)
    },
    onChange5(checked) {
      checked ? this.form.defuseSuccess = 1 : this.form.defuseSuccess = 0
    },
    inputse(val){
      let arr = []
      arr.push(val)
      this.$emit('fileListse',arr)
    },
    showModal(val) {
      this.visible = true;
    },
    handleOk() {
      this.$refs.inpute.handleOk()
    },
    onChange1(date, dateString) {
      console.log(date, dateString);
      this.form.defuseDate = dateString
    },
    onChange2(date, dateString) {
      console.log(date, dateString);
      this.form.caseStartDate = dateString
    },
    onChange3(date, dateString) {
      console.log(date, dateString);
      this.form.terminationDate = dateString
    },
    handleRemove(file) {
      const index = this.fileList.indexOf(file);
      const newFileList = this.fileList.slice();
      newFileList.splice(index, 1);
      this.fileList = newFileList;
    },
    beforeUpload(file) {
      this.fileList = [...this.fileList, file];
      return false;

    },
    resetForm() {
      this.$refs.ruleForm.resetFields();
    },
    // filterMultiDictText(dictCode, text) {
    //   console.log(dictCode,text)
    //   if (!text && text !== 0) return
    //   let datas = getDictItemsFromCache(dictCode)
    //   // return this.$filterMultiDictText(datas, text)
    //   return this.$filterDictText(datas, text)
    // },
    filterMultiDictText1(dictCode, text) {
      // console.log(dictCode,text)
      if (!text && text !== 0) return
      let datas = getDictItemsFromCache(dictCode)
      // return this.$filterMultiDictText(datas, text)
      return this.$filterDictText(datas, text)
    },
    filterMultiDictText(dictCode, text) {
      // console.log(dictCode,text)
      // if (!text && text !== 0) return
      let datas = getDictItemsFromCache(dictCode)
      // console.log(this.$filterDictText(datas, text))
      // return this.$filterMultiDictText(datas, text)
      // return this.$filterDictText(datas, text)
      console.log(datas)
      return datas
    },
    submitForm() {
      this.$refs.ruleForm.validate(valid => {
        console.log(valid)
        // this.passCheck = valid
        this.$emit('passCheck',valid)
      });
    },

  },
  watch:{
    form:{
      deep:true,
      handler(a,b){
        console.log(this.form)
        this.$emit('basicses2',this.form)
      }
    },
  }
}
</script>

<style scoped>
</style>